package com.geekchique.runningbuddy.view;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;

import com.geekchique.runningbuddy.activity.Home;
import com.geekchique.runningbuddy.activity.Stopwatch;
import com.geekchique.runningbuddy.activity.TabsAdapter;
import com.geekchique.runningbuddy.provider.ActivityID;

public class HomeView extends LinearLayout {

	private Home activity;

	public HomeView(Home home, ImageButton stopClock, ImageButton diary) {
		super(home);

		this.activity = home;
		stopClock.setOnClickListener(gotoStopClockListener);
        diary.setOnClickListener(gotoTodayListener);
	}

	private void switchToStopClock() {
		Stopwatch.show(activity);
	}

	private void switchToToday() {
	    Intent intent = new Intent(activity, TabsAdapter.class);
	    Bundle extras = new Bundle();
	    extras.putString("name0", "Today");
	    extras.putString("tab0", "Today");
	    extras.putString("name1", "Calendar");
	    extras.putString("tab1", "Calendar");
	    extras.putInt("default", 0);
	    intent.putExtras(extras);
	    activity.startSubActivity(intent, ActivityID.TODAYJOGS);
	}

	private OnClickListener gotoStopClockListener = new OnClickListener()
	{
		public void onClick(View v)
		{
			switchToStopClock();
		}
	};

	private OnClickListener gotoTodayListener = new OnClickListener()
	{
	  	public void onClick(View v)
	      {
	  		switchToToday();
	      }
	};

}
